package cn.edu.tju.fctl.util;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by catold on 15/12/22.
 * 假期状态类
 * 状态变化情况:
 * 1. 等待审批-一级审批驳回
 * 2. 等待审批-一级审批通过-二级审批驳回
 * 3. 等待审批-一级审批通过-二级审批通过-延期等待审批-...-延期未通过-(第n次)延期等待审批-延期通过
 *
 * 延期申请的状态也是这个,经历的流程也是这样
 */
public enum VacationStatus {
    WAITING_FOR_FIRST_APPLY, FIRST_PASSED,FIRST_BLOCKED,SECOND_PASSED,SECOND_BLOCKED,WAITING_FOR_DELAY_APPLY,DELAY_BLOCKED,DELAY_PASSED;
//    WAITING_FOR_FIRST_APPLY("等待审批"),
//    FIRST_PASSED("一级审批通过", VacationStatus.WAITING_FOR_FIRST_APPLY),
//    FIRST_BLOCKED("一级审批驳回", VacationStatus.WAITING_FOR_FIRST_APPLY),
//    SECOND_PASSED("二级审批通过", VacationStatus.FIRST_PASSED),
//    SECOND_BLOCKED("二级审批驳回", VacationStatus.FIRST_PASSED),
//    WAITING_FOR_DELAY_APPLY("延期等待审批", VacationStatus.SECOND_PASSED, VacationStatus.DELAY_BLOCKED, VacationStatus.DELAY_PASSED),
//    DELAY_BLOCKED("延期未通过", VacationStatus.WAITING_FOR_DELAY_APPLY),
//    DELAY_PASSED("延期通过", VacationStatus.WAITING_FOR_FIRST_APPLY)
    ;

    private String name; // 中文提示
    private List<VacationStatus> allowPreStatusList; // 允许的前置状态

    static {
        WAITING_FOR_FIRST_APPLY.name = "等待审批";
        WAITING_FOR_FIRST_APPLY.allowPreStatusList = new ArrayList();

        FIRST_PASSED.name = "一级审批通过";
        FIRST_PASSED.allowPreStatusList = new ArrayList();
        FIRST_PASSED.allowPreStatusList.add(WAITING_FOR_FIRST_APPLY);

        FIRST_BLOCKED.name = "二级审批驳回";
        FIRST_BLOCKED.allowPreStatusList = new ArrayList();
        FIRST_BLOCKED.allowPreStatusList.add(WAITING_FOR_FIRST_APPLY);

        SECOND_PASSED.name = "二级审批通过";
        SECOND_PASSED.allowPreStatusList = new ArrayList();
        SECOND_PASSED.allowPreStatusList.add(FIRST_PASSED);

        SECOND_BLOCKED.name = "等待审批";
        SECOND_BLOCKED.allowPreStatusList = new ArrayList();
        SECOND_BLOCKED.allowPreStatusList.add(FIRST_PASSED);

        WAITING_FOR_DELAY_APPLY.name = "延期等待审批";
        WAITING_FOR_DELAY_APPLY.allowPreStatusList = new ArrayList();
        WAITING_FOR_DELAY_APPLY.allowPreStatusList.add(SECOND_PASSED);
        WAITING_FOR_DELAY_APPLY.allowPreStatusList.add(DELAY_BLOCKED);
        WAITING_FOR_DELAY_APPLY.allowPreStatusList.add(DELAY_PASSED);


        DELAY_PASSED.name = "延期通过";
        DELAY_PASSED.allowPreStatusList = new ArrayList();
        DELAY_PASSED.allowPreStatusList.add(WAITING_FOR_DELAY_APPLY);

        DELAY_BLOCKED.name = "延期未通过";
        DELAY_BLOCKED.allowPreStatusList = new ArrayList();
        DELAY_BLOCKED.allowPreStatusList.add(WAITING_FOR_DELAY_APPLY);

    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<VacationStatus> getAllowPreStatusList() {
        return allowPreStatusList;
    }

    public void setAllowPreStatusList(List<VacationStatus> allowPreStatusList) {
        this.allowPreStatusList = allowPreStatusList;
    }
}
